package com.weme.common.dialog

import android.content.Context
import androidx.fragment.app.FragmentActivity
import com.weme.common.view.BottomSelectionDialog
import com.weme.common.view.BottomSelectionListener
import com.weme.common.view.SelectionItem

object DialogUtils {

    fun createAndShowBottomSelectionDialog(
        context: FragmentActivity,
        title: String,
        listener: BottomSelectionListener,
    ) {

        val dialog = BottomSelectionDialog.newInstance(createReportList(context,listener))
        dialog.show(context.supportFragmentManager,"BottomSelectionDialog")
        dialog.setTitle(title)
    }

    fun createReportList(context: Context,    listener: BottomSelectionListener,): List<SelectionItem> {
        val reportItems = listOf(
            com.example.resources.R.string.report_1,
            com.example.resources.  R.string.report_2,
            com.example.resources.   R.string.report_3,
            com.example.resources.    R.string.report_4,
            com.example.resources.   R.string.report_5,
            com.example.resources.  R.string.report_6,
            com.example.resources.   R.string.report_7
        )
        val selectionItems = mutableListOf<SelectionItem>()

        reportItems.forEachIndexed { index, resourceId ->
            val item = SelectionItem(
                context.getString(resourceId),
                index,
                object : BottomSelectionListener {
                    override fun onTitleClicked(position: Int) {
                        listener.onTitleClicked(position)
                    }
                }
            )
            selectionItems.add(item)
        }

        return selectionItems
    }
}


